Lego Sherlock Holmes figure focuses a light beam on a Lego criminal with a small magnifying glass.

Mindstorms Speech Synthesis

Sometimes data is better read out as an audio indication, rather than written on a display. A speaking voice can be added to Mindstorms inventions with a speech synthesizer installed on a Raspberry Pi. I used a package called espeak, which can be added by the command:

sudo apt-get install espeak

The resulting voice sound is rather robot like, as can be heard in the video above. The voice reads out measurements from a Mindstorms Ultrasonic Sensor whenever a Mindstorms Touch Sensor is pressed. The Mindstorms sensors are hosted in this example with a BrickPi3 from Dexter Industires. As I used in my blog post on LEGO Drum Machine, I took the audio output from the Raspberry Pi on a USB audio adapter. The BrickPi3 is controlled with a Python program, calling espeak by a function of

def say(something):
os.system('espeak -s125 -ven-us"[0] --stdout | aplay -D plughw:1'.format(something))

prior to this function a library has to be imported:

import os